<template>
	<view class="content">
		<view class="user-top">
			<view class="top-tool">
				
				<image src="../../static/common/sub-order-back.png" class="tool-msg" @tap="goHome"></image>
				<navigator url="../user/setting?id=2" hover-class="none">
					<image src="../../static/common/sub-setimg-cion.png" class="tool-seting"></image>
				</navigator>
			</view>
			<view class="user-info">
				<navigator url="../../pages/subBack/sub-userInfo/sub-userInfo" hover-class="none">
					
					<image src="../../static/common/useravatar.png" class="user-avator" v-if="!apptoken"></image>
					<image v-else :src="userInfo.headimg?getImgUrl(accountInfo.headimg):'../../static/common/default-heading'" class="user-avator"></image>
				
				</navigator>
				
				<view class="user-info-block"  v-if="apptoken">
					<view class="nick-name">{{accountInfo.nickName}}</view>
					<view class="user-id">ID：{{accountInfo.customerId}}</view>
				</view>
				
				<view class="prefect-infor" @tap="myInfor" v-show="!isPrefect">
					<image src="../../static/common/sub-order-img3.png" class="icon-prefect"></image>
					<view class="prefect-infor-text">完善个人信息</view>
				</view>
			</view>
		</view>
		
		<view class="user-bottom">
			<view class="user-baseInfo">
				<navigator url="../../pages/subBack/sub-reward/sub-reward?fundType=8" hover-class="none">
					<view class="baseInfo-item">
						<view class="capital-title">已返还(元)</view>
						<view class="capital-num">{{accountInfo.JieSuanYongjin?accountInfo.JieSuanYongjin:0}}</view>
					</view>
				</navigator>
				
				<!-- <view class="baseInfo-item" @tap="goOrder(2,4)"> -->
				<view class="baseInfo-item">
					<view class="capital-title">待返还(元)</view>
					<view class="capital-num">{{accountInfo.yongJin?accountInfo.yongJin:0}}</view>
				</view>
				
				<navigator url="../../pages/subBack/sub-experience/sub-experience" hover-class="none">
					<view class="baseInfo-item">
						<view class="capital-title">经验值(分)</view>
						<view class="capital-num">{{accountInfo.exp?accountInfo.exp:0}}</view>
					</view>
				</navigator>
			</view>
			
			<view class="sub-order">
				<view class="sub-order-text">超级返订单</view>
				<view class="all-order" @tap="goOrder(2,0)">查看全部></view>
			</view>	
			
			<view class="order-block">
				<view class="order-type" @tap="goOrder(2,0)">
					<image src="../../static/common/sub-order-img1.png" class="order-img"></image>
					<view class="type-text">待操作</view>
				</view>
				<view class="order-type" @tap="goOrder(2,4)">
					<image src="../../static/common/sub-order-img2.png" class="order-img"></image>
					<view class="type-text">待返还</view>
				</view>
			<!-- 	<view class="order-type" @tap="goOrder(2,3)">
					<image src="../../static/common/sub-order-img3.png" class="order-img"></image>
					<view class="type-text">待评价</view>
				</view> -->
				<view class="order-type" @tap="goOrder(2,3)">
					<image src="../../static/common/sub-order-img5.png" class="order-img"></image>
					<view class="type-text">待评价</view>
				</view>
				<view class="order-type" @tap="goOrder(2,5)">
					<image src="../../static/common/sub-order-img4.png" class="order-img"></image>
					<view class="type-text">已返还	</view>
				</view>
			</view>
			
			<view class="sub-order" style="margin-top: 33upx;">
				<view class="sub-order-text">工具服务</view>
			</view>	
			<view class="order-block new-block">
				<view class="order-type" @tap="subCash">
					<image src="../../static/common/sub-order-img6.png" class="order-img"></image>
					<view class="type-text">我要提现</view>
				</view>
				<view class="order-type" @tap="subAppeal">
					<image src="../../static/common/sub-order-img7.png" class="order-img"></image>
					<view class="type-text">申诉管理</view>
				</view>
				<view class="order-type" @click="contactKF">
					<image src="../../static/common/sub-order-img8.png" class="order-img"></image>
					<view class="type-text">联系客服</view>
				</view>
				<view class="order-type" @click="myTeam">
					<image src="../../static/common/my-team.png" class="order-img"></image>
					<view class="type-text">邀请好友</view>
				</view>
				<view class="order-type" @click="myInfor">
					<image src="../../static/common/sub-back-YS-4.png" class="order-img"></image>
					<view class="type-text">我的账号</view>
				</view>
			</view>
			
			<view class="sub-order" style="margin-top: 33upx;">
				<view class="sub-order-text">我的钱包</view>
			</view>	
			<view class="my-team">
				<view class="team-left">
					<view class="team-title">我的本金</view>
					<view class="team-number">{{accountInfo.benjin?accountInfo.benjin:0}}<text>元</text></view>
					<navigator url="../../pages/subBack/sub-reward/sub-benjin" hover-class="none">
						<image src="../../static/common/benjin.png" class="team-invite"></image>
					</navigator>
				</view>
				<view class="line"></view>
				<view class="team-left">
					<view class="team-title">我的佣金</view>
					<view class="team-number">{{accountInfo.yongjin?accountInfo.yongjin:0}}<text>元</text></view>
					<navigator url="../../pages/subBack/sub-reward/sub-reward" hover-class="none">
						<image src="../../static/common/yongjin.png" class="team-invite"></image>
					</navigator>
					
				</view>
			</view>
		</view>	
			
			
		
			
			
		
		
		
	</view>
</template>

<script>
	import uniPopup  from'../../components/uni-popup/uni-popup.vue'
	export default{
		name:"subMe",
		components:{
			uniPopup
		},
		data(){
			return{
				type: 'center',
				apptoken:"",
				userInfo:"",
				accountInfo:"",
				isPrefect:true
			}
		},
		created() {
			//获取用户信息
			this.apptoken = uni.getStorageSync("apptoken")
			this.getAccountInfo();
			this.getUserInfo();
		},
		methods:{
			goOrder(n,type){
				this.$parent.goOrder(n,type);
			},
			getImgUrl(url){
				//处理头像
				if(url && url.indexOf('http')==-1){
					return this.$CommonJS.getBaseImgUrl(url);
				}else{
					return url
				}
			},
			getAccountInfo(){
				//账户信息
				const _this = this;
				uni.request({
					url:this.$API.URL + this.$API.user_revenue,
					data:{apptoken:this.apptoken},
					success(res) {
						console.log(res);
						if(res.data.success){
							_this.accountInfo = res.data.data;
						}
					}
				})
			},
			getUserInfo(){
				//用户信息加载
				const _this = this;
				uni.request({
					url:this.$API.URL + this.$API.user_view,
					data:{apptoken:this.apptoken},
					success(res) {
						console.log(res)
						if(res.data.success){
							_this.userInfo = res.data.data;
							_this.checkPrefect(res.data.data);
						
						}
						
					}
				})
			},
			checkPrefect(data){
				if(!data.address){
					this.isPrefect = false;
				}
				if(!data.sex){
					this.isPrefect = false;
				}
				if(!data.age){
					this.isPrefect = false;
				}
				if(!data.taobaoID){
					this.isPrefect = false;
				}
				if(!data.type){
					this.isPrefect = false;
				}
				if(!data.isHuabei){
					this.isPrefect = false;
				}
				if(!data.taoqizhi){
					this.isPrefect = false;
				}
				if(!data.mLevel){
					this.isPrefect = false;
				}
				if(!data.phone){
					this.isPrefect = false;
				}
				if(!data.qq){
					this.isPrefect = false;
				}
				if(!data.weixin){
					this.isPrefect = false;
				}
			},
			contactKF(){
				this.$CommonJS.navigateTo('../../pages/subBack/sub-kefu/sub-kefu')
			},
			goHome(){
				uni.switchTab({
					url:'../../pages/home/home'
				})
			},
			subAppeal(){
				this.$CommonJS.navigateTo('../../pages/subBack/sub-appeal/sub-appeal')
			},
			subCash(){
				this.$CommonJS.navigateTo('../../pages/subBack/sub-cash/sub-cash')
			},
			myTeam(){
				this.$CommonJS.navigateTo('../../pages/subBack/sub-share/sub-share')
			},
			openOrder(){
				 this.$refs.showshare.open()
			},
			cancel(type) {
				this.$refs['show' + type].close();
				this.$CommonJS.navigateTo('../orderBack/order-back')
			},
			change(e) {
				console.log('是否打开:' + e.show)
			},
			myInfor(){
					this.$CommonJS.navigateTo('../../pages/subBack/sub-userInfo/sub-userInfo')
			}
		}
	}
</script>

<style scoped>
	@import url("sub-me.css");
</style>
